﻿using System;
//using System.Collections.Generic;
//using System.Linq;
//using System.Web;
//using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using MpSoft.Library.BUSS.Categories;

namespace MpSoft.Web.AdminCP.Controls.Modules
{
    public partial class Navigation : System.Web.UI.UserControl
    {
        #region var

        private string controlName = string.Empty;

        #endregion

        #region Method

        public string GetNavigation()
        {
            StringBuilder sb = new StringBuilder();
            sb.Append("<ul>");
            sb.Append("<li><a href='/AdminCP/'>Bảng điều khiển</a><i class='fa fa-angle-right'></i></li>");
            var listNav = NavigateBUSS.Navigate_ByDic();
            if (listNav.ContainsKey(this.controlName))
            {
                var navObj = listNav[this.controlName];
                if (navObj.Level.Equals("2"))
                {
                    var navObj2 = listNav[navObj.Parent.Trim()];
                    sb.Append("<li><a href='" + navObj2.Url + "'>" + navObj2.Title + "</a><i class='fa fa-angle-right'></i></li><li><a href='" + navObj.Url + "'>" + navObj.Title + "</a></li>");
                }
                else
                    sb.Append("<li><a href='" + navObj.Url + "'>" + navObj.Title + "</a></li>");
            }
            else
            {
                sb.Append("<li><a href='/AdminCP/'>Bảng điều khiển</a></li>");
            }
            sb.Append("</ul>");
            return sb.ToString();
        }

        #endregion

        #region Event

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        #endregion

        #region Properties

        public string ControlName
        {
            set { controlName = value; }
            get { return controlName; }
        }

        #endregion
    }
}